package org.toonan.rental.chart;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.Button;

public class ChartMainActivity extends Activity implements View.OnClickListener
{
	private Handler downloadingHandler = new Handler()
	{
		public void handleMessage(Message paramMessage)
		{
			super.handleMessage(paramMessage);
			Animation localAnimation = AnimationUtils.loadAnimation(ChartMainActivity.this,
					R.anim.downloading_anim);
			ChartMainActivity.this.downloadingView.startAnimation(localAnimation);
			ChartMainActivity.this.downloadingView.setVisibility(8);
		}
	};
	private Thread downloadingThread = new Thread()
	{
		public void run()
		{
			try
			{
				Thread.sleep(1000);
				ChartMainActivity.this.downloadingHandler.sendEmptyMessage(0);
				return;
			}
			catch (InterruptedException localInterruptedException)
			{
				while (true)
					localInterruptedException.printStackTrace();
			}
		}
	};
	private View downloadingView;
	
	protected void onCreate(Bundle paramBundle)
	{
		super.onCreate(paramBundle);
		setContentView(R.layout.chart_main);
		this.downloadingView = findViewById(R.id.downloading);
		this.downloadingThread.start();
		initChartButton();
		this.downloadingView.setVisibility(View.GONE);
	}
	
	private void initChartButton()
	{
		int i = 0;
		Button[] arrayOfButton = { (Button) findViewById(R.id.bar_but), (Button) findViewById(R.id.pie_but),
				(Button) findViewById(R.id.thread_but), (Button) findViewById(R.id.exit_but) };
		int j = arrayOfButton.length;
		while (true)
		{
			if (i >= j)
				return;
			arrayOfButton[i].setOnClickListener(this);
			i++;
		}
	}
	
	public void onClick(View paramView)
	{
		Intent localIntent1 = new Intent(this, BarChartActivity.class);
		Intent localIntent2 = new Intent(this, PieChartActivityGroup.class);
		Intent localIntent3 = new Intent(this, ThreadChartActivity.class);
		switch (paramView.getId())
		{
			default:
			case R.id.bar_but:
				startActivity(localIntent1);
			case R.id.pie_but:
				startActivity(localIntent2);
			case R.id.thread_but:
				startActivity(localIntent3);
			case R.id.exit_but:
				finish();
		}
	}
	
}
